<script type="text/javascript">
$(document).ready(function(){
	$("#lv1").change(function () {
          var str = "";
          $("#lv1 option:selected").each(function () {
                str += $(this).val() + " ";
              });
          $("#pid").val(str);
        })
})
</script>
<h3>Product Category  [Add / Edit Form]</h3>
<div></div>
<form enctype="multipart/form-data" method="post" action="admin_product_category/save">
	<table class="tblist2">
		<tr>
			<th>Main category</th>
			<td>
				<select name="lv1" id="lv1">
					<option value="0">--select main category</option>
					<? 
						foreach($main_category as $item):
							$selected = $item['id'] == $pid ? 'selected="selected"' : "";
							echo '<option value="'.$item['id'].'" '.$selected.'>'.$item['name_th'].'</option>';
						endforeach;
					?>
				</select>
				<input type="hidden" name="pid" id="pid" value="<?=@$pid;?>"/>
			</td>
		</tr>
		<tr>
			<th width="150px">Name TH</th>
			<td>
            	<input type="hidden" name="id" value="<?=@$rs['id'];?>" />
            	<input type="text" name="name_th" value="<?=@$rs['name_th'];?>" /> <span class="txtOrange">*</span>
            &nbsp;</td>
		</tr>
		<tr>
			<th>Name EN</th>
			<td>
				<input type="text" name="name_en" value="<?=@$rs['name_en'];?>" /> <span class="txtOrange">*</span>
			</td>
		</tr>
		<tr>			
			<td colspan="2" align="center">
				<input type="submit" value="Save" class=""> <input type="button" value="  Back  " onclick="history.back();"> 
			</td>
		</tr>
	</table>
</form>